const mongoose = require("mongoose")
const ObjectId = mongoose.Schema.Types.ObjectId;
const MovieAndCinemaSchema = new mongoose.Schema({
    movie: { //关联的电影
        type: ObjectId,
        ref: "Movie"
    },
    cinema: { //关联的影院
        type: ObjectId,
        ref: "Cinema"
    },
    screens: [ //关联的影院放映厅，它是一个数组，每一项是一个对象
        {
            name: String, //放映厅名，例如：1号厅
            time: String, //放映时间，例如：12:00
            price: Number //票价，例如：35.00
        }
    ]
}, {
    versionKey: false,
    timestamps: {
        createdAt: 'createTime',
        updatedAt: 'updateTime'
    } //自动管理修改时间
})

module.exports = mongoose.model("MovieAndCinema", MovieAndCinemaSchema);